package com.zxx.pattern.flyweight.fly1;

/**
 * @author zxx on 2021/7/16
 */
public class TestFly1 {
    public static void main(String[] args) {
        MyChar aChar;
        MyChar aChar1;
        MyChar aChar2;
        MyChar aChar3;
        MyChar aChar4;
        MyChar aChar5;

        aChar = MyCharFactory.getInstance().getMyChar(new Character('a'));
        System.out.println("获取享元字符：" + aChar.showMyChar());
        System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());

        aChar1 = MyCharFactory.getInstance().getMyChar(new Character('b'));
        System.out.println("获取享元字符：" + aChar1.showMyChar());
        System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());

        aChar2 = MyCharFactory.getInstance().getMyChar(new Character('c'));
        System.out.println("获取享元字符：" + aChar2.showMyChar());
        System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());

        aChar3 = MyCharFactory.getInstance().getMyChar(new Character('a'));
        System.out.println("获取享元字符：" + aChar3.showMyChar());
        System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());

        aChar4 = MyCharFactory.getInstance().getMyChar(new Character('a'));
        System.out.println("获取享元字符：" + aChar4.showMyChar());
        System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());

        aChar5 = MyCharFactory.getInstance().getMyChar(new Character('d'));
        System.out.println("获取享元字符：" + aChar5.showMyChar());
        System.out.println("当前享元字符数量：" + MyCharFactory.getInstance().getCharCount());

    }
}
